SQL Query not working as expected....

SQL Query not working as expected....

am 24.09.2006 12:52:26 von jerryyang_la1

Hi
I have created a form, for users to enter the name of a file and it
then gets displayed. This works..

I've editted it so the form now search through a few different fields
and tries to match..
This works EXCEPT !!

The field FileKeywords never seems to get searched.. Or more to the
poitn the results are never returned..

Have I screwed up the SQL Query or the writting of the results ??


//Get the number of results
$SearchResult=mysql_query("SELECT * FROM Files WHERE FileTitle LIKE
'%$SearchString%' || FileDescription LIKE '%$SearchString%' ||
FileKeywords LIKE '%$SearchString%' ORDER BY FileTitle") or
die(mysql_error());
$NumberOfResults=mysql_num_rows($SearchResult);

//Get the number of pages
$NumberOfPages=ceil($NumberOfResults/$Limit);

$SearchResult=mysql_query("SELECT * FROM Files WHERE FileTitle LIKE
'%$SearchString%' || FileDescription LIKE '%$SearchString%' ||
FileKeywords LIKE '%$SearchString% 'ORDER BY FileTitle LIMIT " .
($page-1)*$Limit . ",$Limit") or die(mysql_error());

While($row = mysql_fetch_object($SearchResult)) {

Echo "  FileLink . "\"> border=\"0\" src=\"smallicons/" . $row->FileIcon . ".gif\" width=\"20\"
height=\"20\"> $row->FileTitle
- " . $row->FileDescription .
"

";


Many Thanks for your help !!

Re: SQL Query not working as expected....

am 24.09.2006 13:34:22 von zac.carey

Echo " FileLink . "\"> border=\"0\" src=\"smallicons/" . $row->FileIcon . ".gif\" width=\"20\"
height=\"20\"> $row->FileTitle
- " . $row->FileDescription .
"

";

what do the forward slashes after filestore and smallicons mean?

Re: SQL Query not working as expected....

am 24.09.2006 15:20:07 von jerryyang_la1

strawberry wrote:

> Echo " FileLink . "\"> > border=\"0\" src=\"smallicons/" . $row->FileIcon . ".gif\" width=\"20\"
> height=\"20\"> $row->FileTitle
- " . $row->FileDescription .
> "

";
>
> what do the forward slashes after filestore and smallicons mean?

Thats the path.

smallicons/ fileIcon !

Re: SQL Query not working as expected....

am 24.09.2006 16:16:30 von zac.carey

jerryyang_la1@yahoo.com wrote:
> strawberry wrote:
>
> > Echo " FileLink . "\"> > > border=\"0\" src=\"smallicons/" . $row->FileIcon . ".gif\" width=\"20\"
> > height=\"20\"> $row->FileTitle
- " . $row->FileDescription .
> > "

";
> >
> > what do the forward slashes after filestore and smallicons mean?
>
> Thats the path.
>
> smallicons/ fileIcon !

OK - I think you have to escape the closing quotation marks:

\"
filestore/
\"

Re: SQL Query not working as expected....

am 24.09.2006 17:58:01 von jerryyang_la1

Sorted !!

|| FileKeywords LIKE '%$SearchString% ' ORDER BY FileTitle LIMIT " .

The problem was an extra space, the aboe line should have read:

|| FileKeywords LIKE '%$SearchString%' ORDER BY FileTitle LIMIT " .

Re: SQL Query not working as expected....

am 26.09.2006 12:19:53 von Norman Peelman

wrote in message
news:1159104007.301710.20820@i3g2000cwc.googlegroups.com...
>
> strawberry wrote:
>
> > Echo " FileLink . "\"> > > border=\"0\" src=\"smallicons/" . $row->FileIcon . ".gif\" width=\"20\"
> > height=\"20\"> $row->FileTitle
- " . $row->FileDescription .
> > "

";
> >
> > what do the forward slashes after filestore and smallicons mean?
>
> Thats the path.
>
> smallicons/ fileIcon !
>

I see you fixed your SQL problem but... how about,

Echo " src='smallicons/{$row->FileIcon}.gif' width='20'
height='20'>{$row->FileTitle}
- {$row->FileDescription}

\n\r";

....I find this alot easier on the eyes... to include multi-dimensional
arrays ($a['one']['two']) or object properties (as above) you just need to
enclose them in {} within your double quoted strings... and not only that
but now your php code actually looks 99.9% of what you actually expect the
output to be.

Norm
--
FREE Avatar hosting at www.easyavatar.com